home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _CHINS.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  107 lines

  1. #include <string.h>
  2. #define        CURSES_LIBRARY  1
  3. #include <curses.h>
  4.  
  5. #ifndef        NDEBUG
  6. char *rcsid__chins = "$Header: c:/curses/private/RCS/_chins.c%v 2.0 1992/11/15 03:24:24 MH Rel $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   PDC_chins()  - Low-level insert character in window
  15.  
  16.   PDCurses Description:
  17.        This is a private PDCurses routine.
  18.  
  19.        This routine provides the basic functionality for the X/Open
  20.        [mv][w]insch() routines.  The xlat flag indicates that normal
  21.        character translation is performed or not.  If not, then the
  22.        character is output as is.
  23.  
  24.        The 'xlat' flag is TRUE for the normal curses routines.
  25.  
  26.   PDCurses Return Value:
  27.        This function returns OK on success and ERR on error.
  28.  
  29.   PDCurses Errors:
  30.        It is an error to call this function with a NULL window pointer.
  31.  
  32.   Portability:
  33.        PDCurses        int PDC_chins( WINDOW* win, chtype c, bool xlat );
  34.  
  35. **man-end**********************************************************************/
  36.  
  37. int    PDC_chins(WINDOW *win, chtype c, bool xlat)
  38. {
  39.        int     retval = ERR;
  40.        int     x;
  41.        int     y;
  42.        int     maxx;
  43.        int     offset;
  44.        chtype* temp1;
  45.        register chtype*        dstp;
  46.        register chtype*        srcp;
  47.        char    ch      = (c & A_CHARTEXT);
  48.  
  49.        if (win == (WINDOW *)NULL)
  50.                return( retval );
  51.  
  52.        x       = win->_curx;
  53.        y       = win->_cury;
  54.        maxx    = win->_maxx;
  55.        offset  = 1;
  56.        temp1   = &win->_y[y][x];
  57.  
  58. /*
  59.        if ((ch < ' ') &&
  60.            ((ch == '\n') ||
  61.             (ch == '\r') ||
  62.             (ch == '\t') ||
  63.             (ch == '\b')))
  64.        {
  65.                retval = PDC_chadd(win, c, xlat,FALSE);
  66.                return( retval );
  67.        }
  68. */
  69.        if ((ch < ' ') && xlat)
  70.        {
  71.                offset++;
  72.        }
  73.  
  74. #ifdef DOS
  75. #  if  SMALL || MEDIUM
  76.        srcp = temp1;
  77.        dstp = temp1+offset;
  78.        movedata(FP_SEG(srcp), FP_OFF(srcp),
  79.                 FP_SEG(dstp), FP_OFF(dstp),
  80.                 (maxx - x -offset) * sizeof(chtype));
  81. #  else
  82.        /* Changed from memcpy to memmove. Should work with
  83.         * TC and MSC.
  84.         *      -- MH   920605
  85.         */
  86. /*     memmove( temp1 + sizeof(chtype), temp1, (maxx - x -1) * sizeof(chtype) );*/
  87.        memmove( temp1+offset, temp1, (maxx - x -offset) * sizeof(chtype) );
  88. #  endif
  89. #endif
  90. #ifdef OS2
  91.        memmove( temp1+offset, temp1, (maxx - x -offset) * sizeof(chtype) );
  92. #endif
  93.  
  94.        win->_lastch[y] = maxx-1;
  95.  
  96.        if ((win->_firstch[y] == _NO_CHANGE) ||
  97.            (win->_firstch[y] > x))
  98.        {
  99.                win->_firstch[y] = x;
  100.        }
  101.        /*
  102.         * PDC_chadd() fixes CTRL-chars too
  103.         */
  104.        retval = (PDC_chadd(win, c, xlat,FALSE));
  105.        return( retval );
  106. }
  107.